package com.example.medicine.controller;

import com.example.medicine.Bean.zhengzhuang;
import com.example.medicine.Mapper.zyjbMapper;
import com.example.medicine.Mapper.zyzzMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/zyzz")
public class zyzzController {
    @Autowired
    private zyzzMapper zyzzMapper;
    /**
     * 接收zhengzhuangList请求，返回数据库的zhengzhuang表内西医的所有内容，格式为json
     * @return
     */
    @GetMapping("/")
    public List<zhengzhuang> getzyzzList(){
        return zyzzMapper.getAll();
    }
    /**
     * 接收insertzhengzhuang请求，向zhengzhuang中插入内容
     */
    @PostMapping("/")
    public void inserzyzz(@RequestBody zhengzhuang zhengzhuang){
        zyzzMapper.insert(zhengzhuang);
    }

    @PutMapping("/")
    public void updatezyzz(@RequestBody zhengzhuang zhengzhuang){
        zyzzMapper.update(zhengzhuang);
    }

    @DeleteMapping("/{id}")
    public void deletezyzz(@PathVariable String id){
        zyzzMapper.deleteById(id);
    }
}
